<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="rulesArr"
      />
      <van-field
        v-model="password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-field
          v-model="sms"
          center
          clearable
          label="你的钩子"
          placeholder="请输入你的钩子"
          left-icon="chat - o"
          right-icon="smile-o"
        >
          <!-- <van-icon name="smile-o" /> -->
          <template #button>
            <van-button size="small" type="primary">发送验证码</van-button>
            <van-icon name="chat-o" />
          </template>
        </van-field>
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>
<script>
const fn = (value, rule) => {
  const aa = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/
  const rr = aa.test(value)
  return rr
}
export default {
  name: '',
  data () {
    return {
      username: '',
      password: '',
      rulesArr: [{ required: true, message: '请填写用户名' },
      // {pattern:/^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/,message: '手机号格式不对'}
      { validator: fn, message: 'zzzzzzz' }
      ]
    }
  },
  created () {
  },
  computed: {
  },
  methods: {
    onSubmit (values) {
      console.log('submit', values);
    },
  }
}
</script>
<style lang='less'  scoped>
</style>
